<qscms:load type="category" search="1"/>
<div class="modal_fast_creat J_modal_fast_creat">
    <a class="a_close" href="javascript:;"></a>
    <div class="creat_content">
        <div class="step_box">
            <h3>没简历怎么投职位？花30秒轻松填写简历搞定工作</h3>
            <div class="creat_title_box"><span>已有简历，请直接</span><span><a class="btn01 btn_green qulogin toSwitchModal" data-index="1" href="javascript:;">立即登录</a></span></div>
        </div>
        <div class="creat_main">
            <div class="lis">
                <span class="mr18"><input type="text" name="fullname" id="fullname" placeholder="姓名" class="common width177 name"></span>
                <span class="mr18">
                    <div class="common share_ddl width177 J_dropdown J_listitme_parent">
                        <span class="J_listitme_text">期望薪资</span><em></em>
                        <div class="dropdowbox7 J_dropdown_menu">
                            <div class="dropdow_inner7 width197">
                                <ul class="nav_box">
                                    <qscms:classify 列表名="wage_list" 类型="QS_wage" 显示数目="100"/>
                                    <volist name="wage_list" id="wage">
                                        <li><a class="J_listitme" href="javascript:;" data-code="{$key}">{$wage}</a></li>
                                    </volist>
                                </ul>
                            </div>
                        </div>
                        <input class="J_listitme_code" name="wage" id="wage" type="hidden" value=""/>
                    </div>
                </span>
                <span>
                    <div class="sex_radio_list J_radioitme_parent">
                        <div class="n <if condition="$jobs['sex'] eq 1 or $jobs['sex'] eq 0">checked</if> J_radioitme" data-code="1">男</div>
                        <div class="w <if condition="$jobs['sex'] eq 2">checked</if> J_radioitme" data-code="2">女</div>
                        <div class="clear"></div>
                        <input class="J_radioitme_code" name="sex" id="sex" type="hidden" value="<if condition="$jobs['sex'] eq 0">1<else/>{$jobs.sex}</if>"/>
                      </div>
                </span>
                <div class="clear"></div>
            </div>
            <div class="lis">
                <span class="mr18">
                    <div class="common share_ddl width177 J_dropdown J_listitme_parent">
                        <span class="J_listitme_text"><if condition="$jobs['birthdate']">{$jobs['birthdate']}<else/>出生年份</if></span><em></em>
                        <div class="dropdowbox6 J_dropdown_menu">
                            <div class="dropdow_inner6">
                                <ul class="nav_box J_birthdy">
                                    <div class="J_birthday_box active"></div>
                                    <div class="J_birthday_box"></div>
                                    <div class="J_birthday_box"></div>
                                </ul>
                                <a href="javascript:;" class="prev J_birthday_prev"></a>
                                <a href="javascript:;" class="next J_birthday_next"></a>
                            </div>
                        </div>
                        <input class="J_listitme_code" name="birthdate" id="birthdate" type="hidden" value="<if condition="$jobs['birthdate']">{$jobs['birthdate']}</if>" />
                    </div>
                </span>
                <span class="mr18">
                    <div class="common share_ddl width177 J_dropdown J_listitme_parent">
                        <span class="J_listitme_text"><if condition="$jobs['experience'] eq 0">工作经验<else/>{$jobs['experience_cn']}</if></span><em></em>
                        <div class="dropdowbox7 J_dropdown_menu">
                            <div class="dropdow_inner7 width197">
                                <ul class="nav_box">
                                    <qscms:classify 列表名="experience_list" 类型="QS_experience" 显示数目="100"/>
                                    <volist name="experience_list" id="experience">
                                        <li><a class="J_listitme" href="javascript:;" data-code="{$key}">{$experience}</a></li>
                                    </volist>
                                </ul>
                            </div>
                        </div>
                        <input class="J_listitme_code" name="experience" id="experience" type="hidden" value="<if condition="$jobs['experience'] neq 0">{$jobs['experience']}</if>" />
                    </div>
                </span>
                <span>
                    <div class="common share_ddl width177 J_dropdown J_listitme_parent">
                        <span class="J_listitme_text"><if condition="$jobs['education'] eq 0">最高学历<else/>{$jobs['education_cn']}</if></span><em></em>
                        <div class="dropdowbox5 J_dropdown_menu">
                            <div class="dropdow_inner5 width197">
                                <ul class="nav_box">
                                    <qscms:classify 列表名="education_list" 类型="QS_education" 显示数目="100"/>
                                    <volist name="education_list" id="education">
                                        <li><a class="J_listitme" href="javascript:;" data-code="{$key}">{$education}</a></li>
                                    </volist>
                                </ul>
                            </div>
                        </div>
                        <input class="J_listitme_code" name="education" id="education" type="hidden" value="<if condition="$jobs['education'] neq 0">{$jobs['education']}</if>" />
                    </div>
                </span>
                <div class="clear"></div>
            </div>
            <eq name="no_apply" value="1">
            <div class="lis">
                <span class="mr18">
                    <div class="common category J_creat_category" id="J_showmodal_jobs" data-title="请选择期望职位" data-multiple="true" data-maxnum="5" <if condition="C('qscms_category_jobs_level') gt 2">data-width="667"<else/>data-width="520"</if> data-category="{:C('qscms_category_jobs_level')}">
                        <span class="J_resuletitle_jobs">期望职位</span>
                        <input class="J_resultcode_jobs" name="intention_jobs_id" id="intention_jobs_id" type="hidden" value="" />
                    </div>
                </span>
                <span>
                    <div class="common address J_creat_address" data-toggle="funCityModalDia" data-title="请选择工作地区" data-multiple="true" data-maximum="3" data-width="760">
                        <span class="J_resuletitle_city">意向地区</span>
                        <input class="J_resultcode_city" name="district" id="district" type="hidden" value="" />
                    </div>
                </span>
                <div class="clear"></div>
            </div>
            </eq>
            <div class="lis">
                <span><input type="text" name="telephone" id="telephone" placeholder="手机号" class="common width234"></span>
                <span class="mr18"><input type="button" id="getVerfyCodeRes" value="获取验证码" class="btn_verficode"></span>
                <span><input type="text" name="mobile_vcode" id="mobile_vcode" placeholder="手机验证码" class="common width177"></span>
                <div class="clear"></div>
            </div>
            <div class="lis pl16 btns">
                <eq name="no_apply" value="0">
                <input name="intention_jobs_id" id="intention_jobs_id" type="hidden" value="{$jobs.topclass}.{$jobs.category}.{$jobs.subclass}"/>
                <input name="district" id="district" type="hidden" value="{$jobs.district}"/>
                </eq>
                <input type="hidden" name="jid" value="{$jid}">
                <a class=" btn02 btn_blue reg1" id="btnCreatResume" href="javascript:;">立即注册</a>
            </div>
        </div>
    </div>
</div>
<div class="modal_fast_creat" style="display:none">
    <a class="a_close" href="javascript:;"></a>
    <div class="creat_content">
        <div class="step_box">
            <h3>账号登录</h3>
            <div class="creat_title_box"><span>没有简历，请直接</span><span><a class="btn01 btn_green qulogin toSwitchModal" data-index="0" href="javascript:;">立即注册</a></span></div>
        </div>
        <div class="modal_login_group">
            <div class="modal_login_left"></div>
            <div class="modal_login_right">
                <div class="right_all_box">
                    <div class="tit">
                        <div class="switch_login_type">
                            <div class="J_switch_type login_type select">账号登录<div class="bottom_line"></div></div>
                            <div class="J_switch_type login_type">手机动态码登录<div class="bottom_line"></div></div>
                            <div class="clear"></div>
                        </div>
                    </div>
                    <div class="login_type_group">
                        <div class="type_box">
                            <div class="err J_errbox"></div>
                            <div class="inputbox J_focus">
                                <div class="imgbg"></div>
                                <input type="text" class="input_login" name="username" id="username" placeholder="手机号/会员名/邮箱"/>
                            </div>
                            <div class="inputbox J_focus">
                                <div class="imgbg pwd"></div>
                                <input type="password" class="input_login pwd J_loginword" name="password" id="password" placeholder="请输入密码" autocomplete="off" />
                            </div>
                            <div class="btnbox">
                                <input class="btn_login J_hoverbut" type="button" id="J_dologinByAccount" value="登录" />
                            </div>
                            <div class="qqbox">
                                <span class="txt first">
                                    <notempty name="oauth_list">
                                            合作账号登录
                                    </notempty>
                                </span>
                                <div class="appsparent">
                                    <div class="apps">
                                        <volist name="oauth_list" id="oauth">
                                            <a class="ali {$key}" href="{:U('callback/index',array('mod'=>$key,'type'=>'login'))}" title="{$oauth.name}账号登录"></a>
                                        </volist>
                                    </div>
                                </div>
                                <div class="clear"></div>
                            </div>
                        </div>
                        <div class="type_box">
                            <div class="err J_errbox"></div>
                            <div class="inputbox J_focus">
                                <div class="imgbg"></div>
                                <input type="text" class="input_login" name="mobile" id="mobile" placeholder="请输入手机号"/>
                            </div>
                            <div class="inputbox J_focus">
                                <div class="imgbg pwd"></div>
                                <input type="text" class="input_login pwd code J_loginword" name="verfy_code" id="verfy_code" placeholder="请输入手机验证码"  />
                                <input class="btn_login J_hoverbut get_code" type="button" id="getVerfyCode" value="获取验证码" />
                            </div>
                            <div class="btnbox">
                                <input class="btn_login J_hoverbut" type="button" id="J_dologinByMobile" value="登录" />
                            </div>
                            <div class="qqbox">
                                <span class="txt first">
                                    <notempty name="oauth_list">
                                            合作账号登录
                                    </notempty>
                                </span>
                                <div class="appsparent">
                                    <div class="apps">
                                        <volist name="oauth_list" id="oauth">
                                            <a class="ali {$key}" href="{:U('callback/index',array('mod'=>$key,'type'=>'login'))}" title="{$oauth.name}账号登录"></a>
                                        </volist>
                                    </div>
                                </div>
                                <div class="clear"></div>
                            </div>
                        </div>
                        <div class="clear"></div>
                    </div>
                </div>
            </div>
            <div class="clear"></div>
        </div>
    </div>
</div>
<div id="popup-captcha"></div>
<input type="hidden" id="btnCheck" />
<div id="popup-captcha-login"></div>
<input type="hidden" id="btnCheckLogin" />
<input type="hidden" id="verify_userlogin" value="{$verify_userlogin}">
<input type="hidden" id="J_captcha_varify_send" value="{:C('qscms_captcha_config.varify_mobile')}" />
<input type="hidden" id="J_captcha_open" value="{:C('qscms_captcha_open')}" />
<input type="hidden" id="J_loginType" value="0">
<input type="hidden" id="J_sendVerifyType" value="0">
<input type="hidden" id="J_sms_open" value="1">
<script type="text/javascript" src="{:C('TPL_PUBLIC_DIR')}/js/jquery.listitem.js"></script>
<script type="text/javascript" src="{:C('TPL_PUBLIC_DIR')}/js/jquery.dropdown.js"></script>
<script type="text/javascript" src="{:C('TPL_PUBLIC_DIR')}/js/jquery.modal.fastresume.js"></script>
<script type="text/javascript" src="{:C('TPL_PUBLIC_DIR')}/js/jquery.dig.city.js"></script>
<script type="text/javascript">
    // 顶部二维码登录切换
    $(".code_login,.txt_login").click( function () {
        $(".login_type_group").toggle();
        $(".J_qr_code_show").toggle();
        $(".code_login").toggle();
        $(".txt_login").toggle();
        $('.right_all_box .tit').toggle();
    });

    // 关闭窗口
    $('.a_close').die().live('click', function(event) {
        $('.modal').remove();
        $('.modal_backdrop').remove();
    });

    // 登录和注册窗口切换
    $('.toSwitchModal').die().live('click', function(event) {
        var thisInex = $(this).data('index');
        $('.modal_fast_creat').eq(thisInex).show().siblings('.modal_fast_creat').hide();
    });

    // 快速注册发送短信验证码
    var regularMobile = qscms.regularMobile; // 验证手机号正则
    $('input[name="telephone"]').keyup(function(event) {
        var telephoneValue = $(this).val();
        if (telephoneValue.length >= 11) {
            if (telephoneValue != "" && !regularMobile.test(telephoneValue)) {
               $('input[name="telephone"]').addClass('error_creat').focus();
                return false;
            }
        }
    });
    var captcha_open = eval($('#J_captcha_open').val());
    // 点击获取验证码
    $('#getVerfyCodeRes').die().live('click', function() {
        var telephoneValue = $('input[name="telephone"]').val();
        if (!telephoneValue.length) {
            $('input[name="telephone"]').addClass('error_creat').focus();
            return false;
        }
        if (telephoneValue != "" && !regularMobile.test(telephoneValue)) {
           $('input[name="telephone"]').addClass('error_creat').focus();
            return false;
        }
        $('input[name="telephone"]').removeClass('error_creat');
        <if condition="C('qscms_captcha_open') eq 1 && C('qscms_captcha_config.varify_mobile') eq 1">
            qsCaptchaHandler(function(callBackArr) {
                var dataArr = {mobile: $.trim($('input[name="telephone"]').val()),'sms_type':'gsou_reg'};
                $.extend(dataArr, callBackArr);
                $.ajax({
                    url: "{:U('members/reg_send_sms')}",
                    type: 'POST',
                    dataType: 'json',
                    data: dataArr
                })
                .done(function(data) {
                    if (parseInt(data.status)) {
                        setTimeout(function() {
                            disapperTooltip("success", "验证码已发送，请注意查收");
                        },800);
                        // 开始倒计时
                        var countdown = 60;
                        function settime() {
                            if (countdown == 0) {
                                $('#getVerfyCodeRes').prop("disabled", 0);
                                $('#getVerfyCodeRes').removeClass('disabled');
                                $('#getVerfyCodeRes').val('获取验证码');
                                countdown = 60;
                                return;
                            } else {
                                $('#getVerfyCodeRes').prop("disabled", !0);
                                $('#getVerfyCodeRes').addClass('disabled');
                                $('#getVerfyCodeRes').val('重发' + countdown + '秒');
                                countdown--;
                            }
                            setTimeout(function() {
                                settime()
                            },1000)
                        }
                        settime();
                    } else {
                        setTimeout(function() {
                            disapperTooltip("remind", data.msg);
                        },1500)
                    }
                });
            });
        <else/>
            toSetSms();
        </if>
    });
    
    // 发送验证码
    function toSetSms() {
        $.ajax({
            url: "{:U('members/reg_send_sms')}",
            type: 'POST',
            dataType: 'json',
            data: {mobile: $.trim($('input[name="telephone"]').val()),'sms_type':'gsou_reg'}
        })
        .done(function(data) {
            if (parseInt(data.status)) {
                setTimeout(function() { 
                    disapperTooltip("success", "验证码已发送，请注意查收");
                },800)
                // 开始倒计时
                var countdown = 60;
                function settime() {
                    if (countdown == 0) {
                        $('#getVerfyCodeRes').prop("disabled", 0);
                        $('#getVerfyCodeRes').removeClass('disabled');
                        $('#getVerfyCodeRes').val('获取验证码');
                        countdown = 60;
                        return;
                    } else {
                        $('#getVerfyCodeRes').prop("disabled", !0);
                        $('#getVerfyCodeRes').addClass('disabled');
                        $('#getVerfyCodeRes').val('重发' + countdown + '秒');
                        countdown--;
                    }
                    setTimeout(function() { 
                        settime()
                    },1000)
                }
                settime();
            } else {
                setTimeout(function() { 
                    disapperTooltip("remind", data.msg);
                },1500)
            }
        });
    }

    // 创建简历验证
    $('#btnCreatResume').die().live('click', function() {
        var no_apply = eval("{$no_apply}");
        var fullnameValue = $.trim($('input[name="fullname"]').val());
        var sexValue = $.trim($('input[name="sex"]').val());
        var birthdateValue = $.trim($('input[name="birthdate"]').val());
        var educationValue = $.trim($('#education').val());
        var experienceValue = $.trim($('#experience').val());
        var residenceValue = $.trim($('input[name="residence"]').val());
        var intentionJobsValue = $.trim($('#intention_jobs_id').val());
        var districtValue = $.trim($('#district').val());
        var wageValue = $.trim($('#wage').val());
        var telephoneValue = $.trim($('input[name="telephone"]').val());
        var mobile_vcodeValue = $.trim($('input[name="mobile_vcode"]').val());
        var jid = $.trim($('input[name="jid"]').val());
        $('.modal_fast_creat .error_creat').each(function() {
            $(this).removeClass('error_creat');
        });
        if(jid == "" && no_apply==0){
            disapperTooltip("remind", "请选择要申请的职位");
            return false;
        }
        if (intentionJobsValue == "") {
            $('.J_creat_category').addClass('error_creat');
            return false;
        }
        if (wageValue == "") {
            $('input[name="wage"]').closest('.share_ddl').addClass('error_creat');
            return false;
        }
        if (districtValue == "") {
            $('.J_creat_address').addClass('error_creat');
            return false;
        }
        if (experienceValue == "") {
            $('input[name="experience"]').closest('.share_ddl').addClass('error_creat');
            return false;
        }
        if (educationValue == "") {
            $('input[name="education"]').closest('.share_ddl').addClass('error_creat');
            return false;
        }
        if (birthdateValue == "") {
            $('input[name="birthdate"]').closest('.share_ddl').addClass('error_creat');
            return false;
        }
        if (fullnameValue == "") {
            $('input[name="fullname"]').addClass('error_creat').focus();
            return false;
        }
        if (!(fullnameValue.match(/^[\u4e00-\u9fa5]+$/))) {
            $('input[name="fullname"]').addClass('error_creat').focus();
            return false;
        }
        if (fullnameValue != "" && fullnameValue.length > 10) {
            $('input[name="fullname"]').addClass('error_creat').focus();
            return false;
        }
        if (sexValue == "") {
            disapperTooltip("remind", "请选择性别");
            return false;
        }
        if (telephoneValue == "") {
            $('input[name="telephone"]').addClass('error_creat').focus();
            return false;
        }
        if (telephoneValue != "" && !regularMobile.test(telephoneValue)) {
            $('input[name="telephone"]').addClass('error_creat').focus();
            return false;
        }
        if (mobile_vcodeValue == "") {
            $('input[name="mobile_vcode"]').addClass('error_creat').focus();
            return false;
        }
        // 提交表单
        $.ajax({
            url: "{:U('AjaxPersonal/resume_add')}",
            type: 'POST',
            dataType: 'json',
            data: {fullname: fullnameValue, sex: sexValue, birthdate: birthdateValue, education: educationValue, experience: experienceValue, telephone: telephoneValue, intention_jobs_id: intentionJobsValue, district: districtValue, wage: wageValue, mobilevcode: mobile_vcodeValue,jid:jid,no_apply:no_apply}
        })
        .done(function(data) {
            if (parseInt(data.status)) {
                if(data.data.html){
                    $('.modal').remove();
                    $('.modal_backdrop').remove();
                    if(data.data.rid){
                        var qsDialogSons = $(this).dialog({
                            title: '申请职位',
                            yes: function () {
                                var url = "{:U('Personal/index')}";
                                url = url.replace('rid',data.data.rid);
                                location.href = url;
                            },
                            btns: ['完善简历', '放弃申请'],
                            loading: true
                        });
                    }else{
                        var qsDialogSons = $(this).dialog({
                            title: '申请职位',
                            loading: true
                        });
                    }
                    qsDialogSons.setContent(data.data.html);
                }else{
                    if(no_apply==1){
                        $('.modal').remove();
                        $('.modal_backdrop').remove();
                        var qsDialogSons = $(this).dialog({
                            title: '系统提示',
                            loading: true,
                            yes:function(){
                                window.location.href=data.data.url;
                            },
                            cancel:function(){
                                window.location.reload();
                            }
                        });
                        qsDialogSons.setContent(data.data.create_success_html);
                        qsDialogSons.setBtns(['继续完善', '残忍拒绝']);
                    }else{
                        disapperTooltip("remind", data.msg);
                    }
                }
            } else {
                disapperTooltip("remind", data.msg);
            }
        })
        .fail(function(result) {
           disapperTooltip("remind", result.msg);
        });
    });

    // 登录窗口登录方式切换
    var F = -1;
    $('.J_switch_type').click(function() {
        $(this).addClass('select').siblings().removeClass('select');
        var switchIndex = $('.J_switch_type').index(this);
        $('#J_loginType').val(switchIndex);
        $('.login_type_group').stop(true).animate({
            left: 330 * F * switchIndex + "px"
        }, 200);
    });

    // 回车登录
    $('.J_loginword').bind('keypress', function(event) {
        if (event.keyCode == "13") {
            $(this).closest('.type_box').find('.btnbox .btn_login').click();
        }
    });

    // 账号登录验证
    $('#J_dologinByAccount').die().live('click', function() {
        var usernameValue = $.trim($('#username').val());
        var passwordValue = $.trim($('#password').val());
        var $errbox = $(this).closest('.type_box').find('.J_errbox');
        if (usernameValue == "") {
            $errbox.text('请填写手机号/会员名/邮箱').show();
            $('#username').focus();
            return false;
        }
        if (passwordValue == "") {
            $errbox.text('请填写密码').show();
            $('#password').focus();
            return false;
        }
        $errbox.text('').hide();
        if(eval($("#verify_userlogin").val())==1){
            $('#J_sendVerifyType').val('0');
            if (captcha_open) {
                qsCaptchaHandler(function(callBackArr) {
                    var dataArr = new Array();
                    var toType = eval($('#J_sendVerifyType').val());
                    var loginTypeValue = eval($('#J_loginType').val());
                    if (toType) {
                        var mobileValue = $('input[name="mobile"]').val();
                        dataArr = {sms_type: 'login', mobile: mobileValue};
                        $.extend(dataArr, callBackArr);
                        $.ajax({
                            url: "{:U('members/reg_send_sms')}",
                            cache: false,
                            async: false,
                            type: 'post',
                            dataType: 'json',
                            data: dataArr,
                            success: function(result) {
                                if (result.status) {
                                    disapperTooltip("success", "验证码已发送，请注意查收");
                                    // 开始倒计时
                                    var countdown = 60;
                                    function settime() {
                                        if (countdown == 0) {
                                            $('#getVerfyCode').prop("disabled", 0);
                                            $('#getVerfyCode').removeClass('btn_disabled');
                                            $('#getVerfyCode').val('获取验证码');
                                            countdown = 60;
                                            return;
                                        } else {
                                            $('#getVerfyCode').prop("disabled", !0);
                                            $('#getVerfyCode').addClass('btn_disabled');
                                            $('#getVerfyCode').val('重发' + countdown + '秒');
                                            countdown--;
                                        }
                                        setTimeout(function() {
                                            settime()
                                        },1000)
                                    }
                                    settime();
                                } else {
                                    //$('.type_box').eq(loginTypeValue).addClass('err');
                                    $('.type_box').eq(loginTypeValue).find('.J_errbox').text(result.msg).show();
                                    return false;
                                }
                            }
                        });
                    } else {
                        var loginTypeValue = eval($('#J_loginType').val());
                        $('.type_box').eq(loginTypeValue).find('.btnbox .btn_login').val('正在登录中...');
                        if (loginTypeValue) {
                            var mobileValue = $.trim($('input[name=mobile]').val());
                            var verfyCodeValue = $.trim($('input[name=verfy_code]').val());
                            var $errbox = $('#J_dologinByMobile').closest('.type_box').find('.J_errbox');
                            dataArr = {mobile: mobileValue, mobile_vcode: verfyCodeValue};
                            $.extend(dataArr, callBackArr);
                            // 提交表单
                            $.ajax({
                                url: "{:U('members/login')}",
                                type: "post",
                                dataType: "json",
                                data: dataArr,
                                success: function (result) {
                                    if (parseInt(result.status)) {
                                        window.location.reload();
                                    } else {
                                        $errbox.text(result.msg).show();
                                        $('#J_dologinByMobile').val('登录').removeClass('btn_disabled').prop('disabled', 0);
                                        $("#verify_userlogin").val(result.data);
                                    }
                                }
                            });
                        } else {
                            var usernameValue = $.trim($('input[name=username]').val());
                            var passwordValue = $.trim($('input[name=password]').val());
                            var $errbox = $('#J_dologinByAccount').closest('.type_box').find('.J_errbox');
                            dataArr = {username: usernameValue, password: passwordValue};
                            $.extend(dataArr, callBackArr);
                            // 提交表单
                            $.ajax({
                                url: "{:U('members/login')}",
                                type: "post",
                                dataType: "json",
                                data: dataArr,
                                success: function (result) {
                                    if (parseInt(result.status)) {
                                        window.location.reload();
                                    } else {
                                        $errbox.text(result.msg).show();
                                        $('#J_dologinByAccount').val('登录').removeClass('btn_disabled').prop('disabled', 0);
                                        $("#verify_userlogin").val(result.data);
                                    }
                                }
                            });
                        }
                    }
                });
            } else {
                $('#J_dologinByAccount').val('登录中...').addClass('btn_disabled').prop('disabled', !0);
                doLogin();
            }
        }else{
            $('#J_dologinByAccount').val('登录中...').addClass('btn_disabled').prop('disabled', !0);
            doLogin();
        }
    });

    // 手机动态码登录输入手机号时
    $('input[name="mobile"]').keyup(function(event) {
        var $errbox = $(this).closest('.type_box').find('.J_errbox');
        var mobileValue = $(this).val();
        if (mobileValue.length >= 11) {
            if (mobileValue != "" && !regularMobile.test(mobileValue)) {
                $errbox.text('手机号码格式不正确').show();
                return false;
            }
        }
    });

    // 手机动态码登录时获取手机验证码
    $('#getVerfyCode').die().live('click', function(event) {
        var mobileValue = $('#mobile').val();
        var $errbox = $(this).closest('.type_box').find('.J_errbox');
        if (!mobileValue.length) {
            $errbox.text('请输入手机号码').show();
            $('input[name="mobile"]').focus();
            return false;
        }
        if (mobileValue != "" && !regularMobile.test(mobileValue)) {
            $errbox.text('手机号码格式不正确').show();
            $('input[name="mobile"]').focus();
            return false;
        }
        $errbox.text('').hide();
        $('#J_sendVerifyType').val('1');
        if (captcha_open) {
            if (parseInt(qscms.smsTatus)) {
                if (eval($('#J_captcha_varify_send').val())) {
                    qsCaptchaHandler(function(callBackArr) {
                        var dataArr = new Array();
                        var toType = eval($('#J_sendVerifyType').val());
                        var loginTypeValue = eval($('#J_loginType').val());
                        if (toType) {
                            var mobileValue = $('input[name="mobile"]').val();
                            dataArr = {sms_type: 'login', mobile: mobileValue};
                            $.extend(dataArr, callBackArr);
                            $.ajax({
                                url: "{:U('members/reg_send_sms')}",
                                cache: false,
                                async: false,
                                type: 'post',
                                dataType: 'json',
                                data: dataArr,
                                success: function(result) {
                                    if (result.status) {
                                        disapperTooltip("success", "验证码已发送，请注意查收");
                                        // 开始倒计时
                                        var countdown = 60;
                                        function settime() {
                                            if (countdown == 0) {
                                                $('#getVerfyCode').prop("disabled", 0);
                                                $('#getVerfyCode').removeClass('btn_disabled');
                                                $('#getVerfyCode').val('获取验证码');
                                                countdown = 60;
                                                return;
                                            } else {
                                                $('#getVerfyCode').prop("disabled", !0);
                                                $('#getVerfyCode').addClass('btn_disabled');
                                                $('#getVerfyCode').val('重发' + countdown + '秒');
                                                countdown--;
                                            }
                                            setTimeout(function() {
                                                settime()
                                            },1000)
                                        }
                                        settime();
                                    } else {
                                        //$('.type_box').eq(loginTypeValue).addClass('err');
                                        $('.type_box').eq(loginTypeValue).find('.J_errbox').text(result.msg).show();
                                        return false;
                                    }
                                }
                            });
                        } else {
                            var loginTypeValue = eval($('#J_loginType').val());
                            $('.type_box').eq(loginTypeValue).find('.btnbox .btn_login').val('正在登录中...');
                            if (loginTypeValue) {
                                var mobileValue = $.trim($('input[name=mobile]').val());
                                var verfyCodeValue = $.trim($('input[name=verfy_code]').val());
                                var $errbox = $('#J_dologinByMobile').closest('.type_box').find('.J_errbox');
                                dataArr = {mobile: mobileValue, mobile_vcode: verfyCodeValue};
                                $.extend(dataArr, callBackArr);
                                // 提交表单
                                $.ajax({
                                    url: "{:U('members/login')}",
                                    type: "post",
                                    dataType: "json",
                                    data: dataArr,
                                    success: function (result) {
                                        if (parseInt(result.status)) {
                                            window.location.reload();
                                        } else {
                                            $errbox.text(result.msg).show();
                                            $('#J_dologinByMobile').val('登录').removeClass('btn_disabled').prop('disabled', 0);
                                            $("#verify_userlogin").val(result.data);
                                        }
                                    }
                                });
                            } else {
                                var usernameValue = $.trim($('input[name=username]').val());
                                var passwordValue = $.trim($('input[name=password]').val());
                                var $errbox = $('#J_dologinByAccount').closest('.type_box').find('.J_errbox');
                                dataArr = {username: usernameValue, password: passwordValue};
                                $.extend(dataArr, callBackArr);
                                // 提交表单
                                $.ajax({
                                    url: "{:U('members/login')}",
                                    type: "post",
                                    dataType: "json",
                                    data: dataArr,
                                    success: function (result) {
                                        if (parseInt(result.status)) {
                                            window.location.reload();
                                        } else {
                                            $errbox.text(result.msg).show();
                                            $('#J_dologinByAccount').val('登录').removeClass('btn_disabled').prop('disabled', 0);
                                            $("#verify_userlogin").val(result.data);
                                        }
                                    }
                                });
                            }
                        }
                    });
                } else {
                    validDoSomethig();
                }
            } else {
                disapperTooltip("remind", "短信未开启");
            }
        } else {
            validDoSomethig();
        }
    });

    // 手机动态码登录验证
    $('#J_dologinByMobile').die().live('click', function() {
        var mobileValue = $.trim($('#mobile').val());
        var verfyCodeValue = $.trim($('#verfy_code').val());
        var $errbox = $(this).closest('.type_box').find('.J_errbox');
        if (mobileValue == "") {
            $errbox.text('请填写手机号').show();
            $('#mobile').focus();
            return false;
        }
        if (mobileValue != "" && !regularMobile.test(mobileValue)) {
            $errbox.text('手机号码格式不正确').show();
            return false;
        }
        if (verfyCodeValue == "") {
            $errbox.text('请填写手机验证码').show();
            $('#verfy_code').focus();
            return false;
        }
        $errbox.text('').hide();
        if(eval($("#verify_userlogin").val())==1){
            $('#J_sendVerifyType').val('0');
            if (captcha_open) {
                qsCaptchaHandler(function(callBackArr) {
                    var dataArr = new Array();
                    var toType = eval($('#J_sendVerifyType').val());
                    var loginTypeValue = eval($('#J_loginType').val());
                    if (toType) {
                        var mobileValue = $('input[name="mobile"]').val();
                        dataArr = {sms_type: 'login', mobile: mobileValue};
                        $.extend(dataArr, callBackArr);
                        $.ajax({
                            url: "{:U('members/reg_send_sms')}",
                            cache: false,
                            async: false,
                            type: 'post',
                            dataType: 'json',
                            data: dataArr,
                            success: function(result) {
                                if (result.status) {
                                    disapperTooltip("success", "验证码已发送，请注意查收");
                                    // 开始倒计时
                                    var countdown = 60;
                                    function settime() {
                                        if (countdown == 0) {
                                            $('#getVerfyCode').prop("disabled", 0);
                                            $('#getVerfyCode').removeClass('btn_disabled');
                                            $('#getVerfyCode').val('获取验证码');
                                            countdown = 60;
                                            return;
                                        } else {
                                            $('#getVerfyCode').prop("disabled", !0);
                                            $('#getVerfyCode').addClass('btn_disabled');
                                            $('#getVerfyCode').val('重发' + countdown + '秒');
                                            countdown--;
                                        }
                                        setTimeout(function() {
                                            settime()
                                        },1000)
                                    }
                                    settime();
                                } else {
                                    //$('.type_box').eq(loginTypeValue).addClass('err');
                                    $('.type_box').eq(loginTypeValue).find('.J_errbox').text(result.msg).show();
                                    return false;
                                }
                            }
                        });
                    } else {
                        var loginTypeValue = eval($('#J_loginType').val());
                        $('.type_box').eq(loginTypeValue).find('.btnbox .btn_login').val('正在登录中...');
                        if (loginTypeValue) {
                            var mobileValue = $.trim($('input[name=mobile]').val());
                            var verfyCodeValue = $.trim($('input[name=verfy_code]').val());
                            var $errbox = $('#J_dologinByMobile').closest('.type_box').find('.J_errbox');
                            dataArr = {mobile: mobileValue, mobile_vcode: verfyCodeValue};
                            $.extend(dataArr, callBackArr);
                            // 提交表单
                            $.ajax({
                                url: "{:U('members/login')}",
                                type: "post",
                                dataType: "json",
                                data: dataArr,
                                success: function (result) {
                                    if (parseInt(result.status)) {
                                        window.location.reload();
                                    } else {
                                        $errbox.text(result.msg).show();
                                        $('#J_dologinByMobile').val('登录').removeClass('btn_disabled').prop('disabled', 0);
                                        $("#verify_userlogin").val(result.data);
                                    }
                                }
                            });
                        } else {
                            var usernameValue = $.trim($('input[name=username]').val());
                            var passwordValue = $.trim($('input[name=password]').val());
                            var $errbox = $('#J_dologinByAccount').closest('.type_box').find('.J_errbox');
                            dataArr = {username: usernameValue, password: passwordValue};
                            $.extend(dataArr, callBackArr);
                            // 提交表单
                            $.ajax({
                                url: "{:U('members/login')}",
                                type: "post",
                                dataType: "json",
                                data: dataArr,
                                success: function (result) {
                                    if (parseInt(result.status)) {
                                        window.location.reload();
                                    } else {
                                        $errbox.text(result.msg).show();
                                        $('#J_dologinByAccount').val('登录').removeClass('btn_disabled').prop('disabled', 0);
                                        $("#verify_userlogin").val(result.data);
                                    }
                                }
                            });
                        }
                    }
                });
            } else {
                $('#J_dologinByMobile').val('登录中...').addClass('btn_disabled').prop('disabled', !0);
                doLogin();
            }
        }else{
            $('#J_dologinByMobile').val('登录中...').addClass('btn_disabled').prop('disabled', !0);
            doLogin();
        }
    });

    // 登录方法
    function doLogin() {
        var loginTypeValue = eval($('#J_loginType').val());
        $('.type_box').eq(loginTypeValue).find('.btnbox .btn_login').val('正在登录中...');
        if (loginTypeValue) {
            var mobileValue = $.trim($('input[name=mobile]').val());
            var verfyCodeValue = $.trim($('input[name=verfy_code]').val());
            var $errbox = $('#J_dologinByMobile').closest('.type_box').find('.J_errbox');
            // 提交表单
            $.ajax({
                url: "{:U('members/login')}",
                type: "post",
                dataType: "json",
                data: {
                    mobile: mobileValue,
                    mobile_vcode: verfyCodeValue
                },
                success: function (result) {
                    if (parseInt(result.status)) {
                       window.location.reload();
                    } else {
                        $errbox.text(result.msg).show();
                        $('#J_dologinByMobile').val('登录').removeClass('btn_disabled').prop('disabled', 0);
                        $("#verify_userlogin").val(result.data);
                    }
                }
            });
        } else {
            var usernameValue = $.trim($('input[name=username]').val());
            var passwordValue = $.trim($('input[name=password]').val());
            var $errbox = $('#J_dologinByAccount').closest('.type_box').find('.J_errbox');
            // 提交表单
            $.ajax({
                url: "{:U('members/login')}",
                type: "post",
                dataType: "json",
                data: {
                    username: usernameValue,
                    password: passwordValue
                },
                success: function (result) {
                    if (parseInt(result.status)) {
                        window.location.reload();
                    } else {
                        $errbox.text(result.msg).show();
                        $('#J_dologinByAccount').val('登录').removeClass('btn_disabled').prop('disabled', 0);
                        $("#verify_userlogin").val(result.data);
                    }
                }
            });
        }
    }

    // 极验通过之后需要做的操作
    function validDoSomethig() {
        var toType = eval($('#J_sendVerifyType').val());
        var loginTypeValue = eval($('#J_loginType').val());
        if (toType) {
            var mobileValue = $('input[name="mobile"]').val();
            $.ajax({
                url: "{:U('members/reg_send_sms')}",
                cache: false,
                async: false,
                type: 'post',
                dataType: 'json',
                data: { sms_type: 'login', mobile: mobileValue},
                success: function(result) {
                    if (result.status) {
                        disapperTooltip("success", "验证码已发送，请注意查收");
                        // 开始倒计时
                        var countdown = 60;
                        function settime() {
                            if (countdown == 0) {
                                $('#getVerfyCode').prop("disabled", 0);
                                $('#getVerfyCode').removeClass('btn_disabled');
                                $('#getVerfyCode').val('获取验证码');
                                countdown = 60;
                                return;
                            } else {
                                $('#getVerfyCode').prop("disabled", !0);
                                $('#getVerfyCode').addClass('btn_disabled');
                                $('#getVerfyCode').val('重发' + countdown + '秒');
                                countdown--;
                            }
                            setTimeout(function() { 
                                settime()
                            },1000)
                        }
                        settime();
                    } else {
                        //$('.type_box').eq(loginTypeValue).addClass('err');
                        $('.type_box').eq(loginTypeValue).find('.J_errbox').text(result.msg).show();
                        return false;
                    }
                }
            });
        } else {
            doLogin();
        }
    }
</script>